﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using MyLocalChurch.Models.Resources;

namespace MyLocalChurch.Models
{
    public abstract class ATracker
    {
        private string _createdBy;
        private DateTime _createdDate;

        [Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ErrorMessages))]
        [StringLength(200)]
        public string CreatedBy
        {
            get { return _createdBy; }
            set
            {
                _createdBy = value;

                if (ModifiedBy == default(string))
                    ModifiedBy = value;
            }
        }

        [Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ErrorMessages))]
        [DataType(DataType.DateTime, ErrorMessageResourceName = "Invalid", ErrorMessageResourceType = typeof(ErrorMessages))]
        public DateTime CreatedDate
        {
            get { return _createdDate; }
            set
            {
                _createdDate = value;

                if (ModifiedDate == default(DateTime))
                    ModifiedDate = value;
            }
        }

        [Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ErrorMessages))]
        [StringLength(200)]
        public string ModifiedBy { get; set; }

        [Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ErrorMessages))]
        [DataType(DataType.DateTime, ErrorMessageResourceName = "Invalid", ErrorMessageResourceType = typeof(ErrorMessages))]
        public DateTime ModifiedDate { get; set; }

        [Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ErrorMessages))]
        public bool IsActive { get; set; }
    }
}